import { loadOptions } from '@babel/core';

export const C = 'abcdefghijklmnopqrstuvwxyz';
export const N = '0123456789';
export const UC = C.toUpperCase();
export const CONFIG_FILES = ['sitemap.json', 'ext.json', 'project.config.json'];
export const SERIALIZER_CONFIG = { decodeEntities: false, selfClosingTags: true, xmlMode: true, emptyAttrs: true };
export const BASE_TARGET = ['app', 'custom-tab-bar/index'];
export const PERMISSIBLE_FILE_TYPES = [
  'png',
  'jpg',
  'jpeg',
  'gif',
  'cer',
  'mp3',
  'aac',
  'm4a',
  'mp4',
  'wav',
  'ogg',
  'silk',
  'wasm',
  'br',
];
export const WX_PAGE_JSON_KEYS = [
  'navigationBarBackgroundColor',
  'navigationBarTextStyle',
  'navigationBarTitleText',
  'navigationStyle',
  'backgroundColor',
  'backgroundTextStyle',
  'backgroundColorTop',
  'backgroundColorBottom',
  'enablePullDownRefresh',
  'onReachBottomDistance',
  'pageOrientation',
  'disableScroll',
  'usingComponents',
  'initialRenderingCache',
  'style',
  'singlePage',
  'restartStrategy',
  'visualEffectInBackground',
];
/**
 * 压缩xml的config
 */
export const MINIFY_XML_CONFIG = {
  caseSensitive: true,
  collapseBooleanAttributes: false,
  collapseWhitespace: true,
  conservativeCollapse: false,
  collapseInlineTagWhitespace: false,
  preserveLineBreaks: false,
  continueOnParseError: false,
  // customAttrAssign: [],
  // customAttrCollapse:
  // customAttrSurround
  // customEventAttributes
  decodeEntities: false,
  html5: true,
  // ignoreCustomComments:
  ignoreCustomFragments: [/\{\{.*?}}/],
  includeAutoGeneratedTags: false,
  keepClosingSlash: true,
  // maxLineLength:
  minifyCSS: false,
  minifyJS: false,
  minifyURLs: false,
  preventAttributesEscaping: false,
  processConditionalComments: false,
  // processScripts: []
  quoteCharacter: '"',
  removeAttributeQuotes: false,
  removeComments: true,
  removeEmptyAttributes: false,
  removeEmptyElements: false,
  removeOptionalTags: false,
  removeRedundantAttributes: false,
  removeScriptTypeAttributes: false,
  removeStyleLinkTypeAttributes: false,
  removeTagWhitespace: true,
  sortAttributes: false,
  sortClassName: false,
  trimCustomFragments: false,
  useShortDoctype: false,
};
/**
 * 压缩JS的babel config
 */
export const JS_BABEL_CONFIG = loadOptions({
  sourceType: 'module',
  minified: false,
  presets: [
    [
      'minify',
      {
        builtIns: false,
        mangle: false,
        removeConsole: true,
        removeDebugger: true,
      },
    ],
  ],
});
/**
 * 压缩wxs的babel config
 */
export const XS_BABEL_CONFIG = loadOptions({
  sourceType: 'module',
  minified: true,
  comments: false,
  presets: [
    [
      'minify',
      {
        builtIns: true,
        mangle: true,
        mergeVars: false,
        removeConsole: true,
        removeDebugger: true,
        numericLiterals: false,
      },
    ],
  ],
});
/**
 * 压缩xml表达式的babel config
 */
export const XML_BABLE_CONFIG = loadOptions({
  presets: [
    [
      'minify',
      {
        booleans: false,
        builtIns: false,
        consecutiveAdds: false,
        deadcode: false,
        evaluate: true,
        flipComparisons: false,
        guards: true,
        infinity: true,
        mangle: false,
        memberExpressions: true,
        mergeVars: false,
        numericLiterals: false,
        propertyLiterals: true,
        regexpConstructors: false,
        removeUndefined: false,
        removeConsole: false,
        removeDebugger: false,
        replace: false,
        simplify: false,
        simplifyComparisons: false,
        typeConstructors: false,
        undefinedToVoid: false,
      },
    ],
  ],
});
